// STD3DES.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "fdes.h"
#include "fdes.c"

extern "C" __declspec(dllexport)  char*  __stdcall C3DES_ENCRYPT(char *KeyOrigin, char *TxtOrigin)
{

	unsigned char * keyUnsign = (unsigned char*)KeyOrigin;
	unsigned char * txtUnsign = (unsigned char*)TxtOrigin;
	unsigned char * outUnsign = (unsigned char*)malloc(MAX_COMMBUF);
	memset(outUnsign, 0x00, sizeof(outUnsign));

	long out_len = 0;
	int mode1  = 1;

	tdes_ecb(txtUnsign, strlen((const char*)txtUnsign), outUnsign, &out_len, keyUnsign, strlen((const char*)keyUnsign), mode1);
	return (char*)outUnsign;
}

extern "C" __declspec(dllexport) char*  __stdcall C3DES_DECRYPT(char *KeyOrigin, char *TxtOrigin)
{
	unsigned char *keyUnsign = (unsigned char*)KeyOrigin;
	unsigned char *txtUnsign = (unsigned char*)TxtOrigin;

	unsigned char * outUnsign = (unsigned char*)malloc(MAX_COMMBUF);
	memset(outUnsign, 0x00, sizeof(outUnsign));

	long out_len = 0;
	int mode1 = 0;

	tdes_ecb(txtUnsign, strlen((const char*)txtUnsign), outUnsign, &out_len, keyUnsign, strlen((const char*)keyUnsign), mode1);
	return (char*)outUnsign;
}
